package com.itic.mall.system.orders.orderJDLeadInto.service;

import com.itic.appbase.framework.common.service.CrudService;
import com.itic.appbase.framework.utils.StringHelper;
import com.itic.mall.system.inter.orders.orderJDLeadInto.persistence.dao.OrderJDLeadIntoDao;
import com.itic.mall.system.inter.orders.orderJDLeadInto.persistence.model.OrderJDLeadInto;
import com.itic.mall.system.inter.orders.orderJDLeadInto.persistence.model.OrderJDLeadIntoExample;
import com.itic.mall.system.inter.orders.orderJDLeadInto.persistence.model.OrderJDLeadIntoExample.Criteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional
public class OrderJDLeadIntoService
     extends CrudService<OrderJDLeadIntoDao,OrderJDLeadInto,OrderJDLeadIntoExample> {
    @Autowired
    private OrderJDLeadIntoDao orderJDLeadIntoDao;
    
    /**
	 * 根据店主ID查找店主的预估京东订单，但未转为累计的
	 * @param yunUserId
	 * @return
	 */
	public List<String> getPreOrderNums(String yunUserId){
		List<String> orderNums = null;
		if(StringHelper.isNotBlank(yunUserId)){
			orderNums = this.orderJDLeadIntoDao.getPreOrderNums(yunUserId);
		}
		return orderNums;
	}
	/**
	 * 根据取消状态获取预估订单
	 * @param orderNum
	 * @return
	 */
	/*public List<String> getCancledOrderNums(String yunUserId,String is_cancel){
		List<String> orderNos = null;
		if(StringHelper.isNotBlank(yunUserId) && StringHelper.isNotBlank(is_cancel)){
			this.orderJDLeadIntoDao.getMarkedOrderNums(yunUserId, is_cancel);
		}
		return orderNos;
	}*/
    public OrderJDLeadInto getOrderJDLeadIntoByOrderNum(String orderNum) {
    	OrderJDLeadIntoExample example = new OrderJDLeadIntoExample();
    	Criteria criteria = example.createCriteria();
    	criteria.andOrderNumEqualTo(orderNum);
    	List<OrderJDLeadInto> orderJDLeadIntos = this.list(example);
    	if(orderJDLeadIntos.isEmpty())
    		return null;
    	return orderJDLeadIntos.get(0);
    }
}